package com.yy.studyspringboot.task.quartz;

import org.quartz.*;

import java.time.LocalDateTime;

@DisallowConcurrentExecution //打上这个注解后，quarzt就不会并发执行，而是上个任务执行结束后才执行下一个任务
@PersistJobDataAfterExecution //持久化JobDetail中的jobDataMap(对Trigger中的dataMap无效)
public class MyJob implements Job {

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        System.out.println("myjob execute:" + LocalDateTime.now());

        //从dataMap中取值
        System.out.println(context.getJobDetail().getJobDataMap().get("job1DataKey"));
        System.out.println(context.getTrigger().getJobDataMap().get("trigger1Key"));
        System.out.println(context.getMergedJobDataMap().get("trigger1Key"));
    }

}